package jmine.tec.batch.dao;

import java.util.Collection;

import jmine.tec.batch.domain.MPhase;
import jmine.tec.batch.domain.PhaseInstance;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import bancosys.tec.persist.dao.BaseDAO;
import bancosys.tec.utils.date.Date;

/**
 * DAO da PhaseInstance.
 */
public class PhaseInstanceDAO extends BaseDAO<PhaseInstance<?>> {
    /**
     * Seleciona PhaseInstance por {@link MPhase} e data.
     * 
     * @param phase a definição da fase.
     * @param date a data.
     * @return Coleção de PhaseInstance.
     */
    public Collection<PhaseInstance<?>> findByPhaseAndDate(MPhase phase, Date date) {
        Criteria crit = this.getSession().createCriteria(PhaseInstance.class);
        crit.add(Restrictions.eq("phase", phase));
        crit.add(Restrictions.eq("data", date));
        return this.executeQuery(crit);
    }
}
